﻿namespace Reap.AzureResource.Data.Infrastructure {
	using Reap.AzureResource.Model.Models;
	using Reap.Common.Runtime.Dependency;

	[Dependency(typeof(IDatabaseFactory),ComponentLifeStyle.InRequestScope,Key = "IDatabaseFactory")]
	public class DatabaseFactory:Disposable,IDatabaseFactory {
		#region Fields

		private AzureResourceContext dbContext;

		#endregion

		#region Public Methods and Operators

		public AzureResourceContext Get() {
			return this.dbContext ?? (this.dbContext = new AzureResourceContext());
		}

		#endregion

		#region Methods

		protected override void DisposeCore() {
			if(this.dbContext != null) {
				this.dbContext.Dispose();
			}
		}

		#endregion
	}
}